<?
include('inc/addondb.php');
if(isset($_POST['user'])){
$x = mysql_fetch_object(mysql_query("SELECT * FROM `tweet` WHERE `id`='{$_POST['id']}'"));
$check = mysql_num_rows(mysql_query("SELECT * FROM `tweeted` WHERE `user_id`='{$_POST['user']}' AND `site_id`='{$_POST['id']}'"));
if($_POST['user'] != "" && $_POST['id'] != "" && $check == 0){
mysql_query("UPDATE `users` SET `coins`=`coins`+'{$x->cpc}' WHERE `id`='{$_POST['user']}'");
mysql_query("UPDATE `tweet` SET `visits`=`visits`+'1', `points`=`points`-'{$x->cpc}' WHERE `id`='{$_POST['id']}'");

mysql_query("INSERT INTO `tweeted` (user_id, site_id) VALUES('{$_POST['user']}','{$_POST['id']}')");
}}
?>